<%--
    fileName      : /msgmgmt/msgsystem.jsp
    author        : mlw
    createDate    : 2016-05-11  
    lastModifier  : mlw
    lastModifyDate: 2016-05-11       
    description   : 列表页面
--%>
<%@ page language='java' contentType='text/html; charset=UTF-8' pageEncoding='UTF-8' %>
<%@ taglib uri='ctp-tag' prefix='ctp' %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
        <title></title>

        <ctp:include items='public,validator,groupbox,borderlayout,panel,form,button,toolbar,gridlayout,label,textfield,combobox,checkboxgroup,datepicker,grid,menus,chain,message_ex,link'/>

        <script type='text/javascript' kind='variant'>

            var borderlayout1;
            var querycondition;       //查询条件
            var queryForm;
            var queryGridlayout;
            var msgTitle; //msgTitle
            var pushTime; //pushTime
            var reset;                //重置    
            var submit;               //提交
            var v_msgsystemId = "";		  //方法域中记录问题ID的变量
            var v_urlFirst='';
            var openFrom = '0';
            var queryGroupbox;
        </script>
        <script type='text/javascript' kind='event'>

	        /*
	         * @method addRecord
	         * @desc  新增信息
	         * @author mlw
	         */
 			function addRecord(){
     			window.location.href="<ctp:url href='msgsystemmain.flowc' flowActionName='msgsystemdetail'/>" + "&flag=0"
            }
            /*
	         * @method isChecked
	         * @desc  判断是否已选择数据
	         * @author mlw
	         */
           	function isChecked(){
           		v_msgsystemId = prolist.getSelectedRowId();
           		if(v_msgsystemId != null && v_msgsystemId != ""){
               		return true;
               	}else{
                   	return false;
                }
            }
           	/*
	         * @method modifyRecord
	         * @desc  修改信息
	         * @author mlw
	         */
            function modifyRecord(){
            	
                if(isChecked()){
                	var selects = prolist.getAllSelectedRowId();
                	if(selects.length > 1){
                		ctpMSB.alert({message:'<ctp:label key="mondify_one_record"/>',title:'<ctp:label key="tips_msg"/>',btn:[['确定','OK']],closeBtn:false});
                		return;
                    }
                	window.location.href="<ctp:url href='msgsystemmain.flowc' flowActionName='msgsystemdetail'/>" + "&flag=1"+"&msgId="+v_msgsystemId;
                }else{
                	ctpMSB.alert({message:'<ctp:label key="select_data"/>',title:'<ctp:label key="tips_msg"/>',btn:[['确定','OK']],closeBtn:false});
                }  
            	 
             
            }
            /*
	         * @method modifyRecord
	         * @desc  查看信息
	         * @author mlw
	         */
            function viewRecord(){
            	
                if(isChecked()){
                	var selects = prolist.getAllSelectedRowId();
                	if(selects.length > 1){
                		ctpMSB.alert({message:'<ctp:label key="mondify_one_record"/>',title:'<ctp:label key="tips_msg"/>',btn:[['确定','OK']],closeBtn:false});
                		return;
                    }
                	window.location.href="<ctp:url href='msgsystemmain.flowc' flowActionName='msgsystemdetail'/>" + "&flag=2"+"&msgId="+v_msgsystemId;
                }else{
                	ctpMSB.alert({message:'<ctp:label key="select_data"/>',title:'<ctp:label key="tips_msg"/>',btn:[['确定','OK']],closeBtn:false});
                }  
            	 
             
            }
			/*
	         * @method delHandler
	         * @desc  删除Handler
	         * @author mlw
	         */
			function delHandler(tp){
				if(tp == "ok"){
					ctp.data.getJSONA({	
						url:'<ctp:url href="msgsystemmain.flowc" flowActionName="delmsgsystem"/>',
						reqData : "msgId=" + v_msgsystemId,
						success :function(data){
									if(data && data[0].retCode =="0"){
										ctpMSB.alert({title :'<ctp:label key="delete_record"/>', message:'<ctp:label key="delete_succ"/>'});
										var url = '<ctp:url href="msgsystemmain.flowc" flowActionName="querymsgsystem" params="language=\'zh_CN\';begNum=1;fetchNum=1;"/>';
										prolist.loadData(url);
									}							
									else {
										ctpMSB.alert({title:'<ctp:label key="delete_record"/>',message:'<ctp:label key="delete_fail"/>'});
									}
								}
					});
			 	}
			}
			/*
	         * @method deleteRecords
	         * @desc  删除信息
	         * @author mlw
	         */      
            function deleteRecords(){
                var confirmFlag = false;
                /*如果选择了数据，弹出确认删除对话框*/
                if(isChecked()){
        			ctpMSB.confirm({
        				title:'<ctp:label key="delete_record"/>',
        				message:'<ctp:label key="delete_continue"/>',
        				handler:delHandler
        			  });
                }else{
                	ctpMSB.alert({message:'<ctp:label key="delete_select"/>',title:'<ctp:label key="error_tips"/>',btn:[['确定','OK']],closeBtn:false});
                }
            }
            /*
	         * @method submitForm
	         * @desc  表单提交
	         * @author mlw
	         */ 
            function submitForm(){
            	var url='<ctp:url href="msgsystemmain.flowc" flowActionName="querymsgsystem" params="language=\'zh_CN\';begNum=1;fetchNum=1;"/>'+getQueryInfo();
            	prolist.loadData(url);
            }
            /*
	         * @method resetForm
	         * @desc  表单重置
	         * @author mlw
	         */ 
            function resetForm(){
            	queryForm.reset();
            }

            /*
	         * @method getQueryInfo
	         * @desc  获取表单查询条件
	         * @author mlw
	         */ 
            function getQueryInfo(){
                var queryInfo = "&msgTitle=" + encodeURI(msgTitle.getValue())  					
					+"&pushTime=" + encodeURI(pushTime.getValue())
                	+"&pushTime1=" + encodeURI(pushTime1.getValue());
                return queryInfo;
            }

            /*
	         * @method queryInfosExport
	         * @desc  查询结果导出
	         * @author mlw
	         */ 
            function queryInfosExport(){
                var url='<ctp:url href="msgsystemmain.flowc" flowActionName="opFileExport"/>'+getQueryInfo();
                window.location.href=url;
            }
            
        </script>
        <script type='text/javascript' kind='ui'>

            $(window).load(function(){
      		     //================================UI变量定义片段============================================================

						msgTitle = new ctp.ui.textfield ({//msgTitle
							id : 'msgTitle' ,
							width:'180px',
							type : 'text'
						});	
										
					pushTime = new ctp.ui.datepicker ({//pushTime
							id : 'pushTime' ,
							width:'180px',
							isInput:true,
							showTime :true });	

					pushTime1 = new ctp.ui.datepicker ({//pushTime
						id : 'pushTime1',
						width:'180px', 
						isInput:true,
						showTime :true
						 });	

				
                 submit = new ctp.ui.button({//提交
                     id:'submit'
                 });

                 reset = new ctp.ui.button({//重置
                     id:'reset'
                 });

                 queryGridlayout = new ctp.ui.gridlayout({
                     id: 'queryGridlayout',
                     width: '850px',
                     align: 'center',
                     defaults:{
             			align: 'center',
             			label: {width: '100px'},
            			element:{
            				//默认创建textfield组件
            				type: 'textfield',
            				//默认的组件自带属性,width设成'100%'或不传，则该组件和关联标签的宽度之和会占满所在的列
            				options:{width: '120px'}
            			}
                         			
             		 },
                                  
                     items: [

      				[
						{
                                label: {
                                    id: 'label0', 
                                    text: '<ctp:label key="msgTitle"/>', 
                                    width: '100px'
                                }, 
                                element: msgTitle
                        }],
                        [

						{
                                label: {
                                    id: 'label1', 
                                    text: '起始时间', 
                                    width: '100px'
                                }, 
                                element: pushTime
                        },
                        {
                            label: {
                                id: 'label2', 
                                text: '截止时间', 
                                width: '100px'
                            }, 
                            element: pushTime1
                    }]                        
                	                     ]
                 });
                 
                queryForm = new ctp.form({
                    id: 'queryForm',
                    items: [
						queryGridlayout
                    ],
                    postType:'ajax',
                    buttons : [{                           
	                        id: 'submit',              
	                        text: '<ctp:label key="submit"/>',                  
	                        icon:'apply',
	                        onClick: submitForm 
                 		}, {                                 
	                       id: 'reset',             
	                       text: '<ctp:label key="reset"/>',                   
	                       icon:'reload',
	                       onClick: resetForm
                 	    }]	
                });

                queryGroupbox = new ctp.ui.groupbox({
             		id:'queryGroupbox',
             		align :'center',
             		icon :'',
             		items:[queryForm]
                 });

                querycondition = new ctp.ui.panel({
                    id: 'querycondition',
                    contentPadding :'20px',
                    title: '<ctp:label key="query"/>',
                    items: [
						queryForm
                    ]
                });
                toolbar1 = new ctp.ui.toolbar({
                    id: 'toolbar1',
                    leftItems: [
                        {
                            type: 'button',
                            id: 'add',
                            name: 'add',
                            text: '<ctp:label key="add"/>',
                            icon: 'add',
                            onClick : addRecord
                        }
                        ,
                        '-'
                        ,
                        {
                            type: 'button',
                            id: 'modify',
                            name: 'modify',
                            text: '<ctp:label key="modify"/>',
                            icon: 'edit',
                            onClick : modifyRecord
                        },
                        '-'
                        ,
                        {
                            type: 'button',
                            id: 'delete',
                            name: 'delete',
                            text: '<ctp:label key="delete"/>',
                            icon: 'delete',
                            onClick : deleteRecords
                        },
                        /*
                        ,
                        '-'
                        ,
                        {
                            type: 'button',
                            id: 'ExcelExport',
                            name: 'ExcelExport',
                            text: '<ctp:label key="export"/>',
                            icon: 'down',
                            onClick : queryInfosExport
                        }
                        */
                        '-'
                        ,
                        {
                            type: 'button',
                            id: 'view',
                            name: 'view',
                            text: '<ctp:label key="view"/>',
                            icon: 'collapse-all',
                            onClick : viewRecord
                        }
                        
                    ]
                });

                prolist = new ctp.ui.grid({
                    id: 'prolist',
                    title:'列表',
                    toolbar:toolbar1,
                    toolbarPos:'innertop',
                    url: '<ctp:url href="msgsystemmain.flowc" flowActionName="querymsgsystem" params="language=\'zh_CN\';begNum=1;fetchNum=1;"/>',
                    header: {
                        title: [
                            [
                                {text: '',width: '80px'}
                                ,
								
									{			
										text: '<ctp:label key="msgTitle"/>'
									},								
									{			
										text: '<ctp:label key="msgCont"/>'
									},
									{			
										text: '推送消息类型'
									},	
									{			
										text: '推送设备类型'
									},	
									{			
										text: '<ctp:label key="pushTime"/>'
									},
									{			
										text: '<ctp:label key="deliverNum"/>'
									}								                                
                            ]
                        ],
                        rowIdFieldName: "msgId",
                        attr: [
							{colType: 'radiobox'},

                            {	
	                            	fieldName: 'msgTitle'
									                            },
                            {	
	                            	fieldName: 'msgCont'
									                            },
							{	
									fieldName: 'msgType'
																},
							{	
									fieldName: 'divType'
																},
                            {	
	                            	fieldName: 'pushTime'
									                            },
                            {	
	                            	fieldName: 'deliverNum'
									                            }                                                       
                        ]
                    },
                    footer: {
						auto:true                    
                    }
                });

              
                borderlayout1 = new ctp.ui.borderlayout({
                    id:'borderlayout1',
                    type: '2E',
                    north__size: 0.3,
                    north__items:[querycondition],
                    center__items:[prolist],
                    north__closable:false,
                    north__resizable : true,
                    renderTo: 'body'
                });
            });
        </script>


    </head>
    <body>

        <ctp:form name="queryForm" method="post" action="msgsystemmain.flowc" flowActionName="">
        	
        </ctp:form>

    </body>
</html>
